package main

import "fmt"

type Person interface {
	Eat()
	Speak(word string)
}

type Stu struct {
	Name string
}

func (stu Stu) Eat() {
	fmt.Println(stu.Name, "执行了eat方法")
}

func (stu Stu) Speak(word string) {
	fmt.Println(stu.Name, "执行了eat方法,说...", word)
}

func ShowName(obj Person) {
	obj.Eat()
}

func main() {
	stu := Stu{
		Name: "lijun",
	}

	stu.Eat()
	stu.Speak("汉语")

	stu1 := Stu{
		Name: "小红",
	}

	stu2 := Stu{
		Name: "小明",
	}

	// 多态
	ShowName(stu1)
	ShowName(stu2)
}
